package org.angelica.enums;


import org.angelica.utils.common.SpringContextUtil;

/**
 * redis Key的前缀和超时时间.
 * @author aizhimin
 */
public enum RedisKeyEnum {
	//一次请求的唯一标识 60s 过期
	NONCE("nonce:", 60 ),
	//禁用用户，-1代表永久
	FORBIDDEN_USER("forbid_user:",-1),
	//权限字符串
	PERMISSION("perms:",24 * 60 * 60),
	;

	private String prefix;
	private int expiredTime;

	RedisKeyEnum(String prefix) {
		this.prefix = prefix;
	}
	RedisKeyEnum(String prefix, int expiredTime) {
		this.prefix = prefix;
		this.expiredTime = expiredTime;
	}

	public String getPrefix() {
	    //设置运行环境前缀
	    String active = SpringContextUtil.getActiveProfile();
		return active + ":" + prefix;
	}

	public int getExpiredTime() {
		return expiredTime;
	}
}
